﻿@model QDT.Core.Members.UserAutoBid
@{
    ViewBag.Title = "用户自动投标设置";
}

@section Head{
<link href="/Content/Default/CSS/Safe_Center.css" rel="stylesheet" type="text/css" />
    <style>
        .autobid_form_table { margin-left: 8px; }
        .autobid_form_table tr { height: 38px; }
        .autobid_form_table tr .title { float: right;padding-right: 8px; }
        .autobid_form_table tr .content { text-align: left; }
        .autobid_form_table.diy tr { padding-bottom: 18px; }
        .auto-btn {padding: 8px 10px;width: 180px;font-size: 12px;background-color: #fff}
    </style>
}

<script type="text/javascript" src="@Url.Content("~/Content/Default/JS/jquery.validate.js")"> </script>
<script type="text/javascript" src="@Url.Content("~/Content/Default/JS/messages_zh.js")"> </script>

<script type="text/javascript">
    $().ready(function () {
        $("#AutoBidProject").css("background", "#e0524b");
        $("#AutoBidProject i,#AutoBidProject span").css("color", "white");
        $("#AutoBidProject .san-jiaoxing").css("display", "block");
    });
</script>

<div class="">
    @Html.Action("_UserBanner")
    <div class="ui-inner">
        <div class="ui-grid-row">

            @Html.Action("UserMenu", new {route = MenuRoute.AutoBidProject})

            <div class="ui-grid-20" style="width: 758px; margin: 0; height: 520px;">

                <div class="ui-box">
                    <span style="margin-bottom: 10px; font-size: 18px; display: inline-block;">自动投标</span><br/>
                    <span style="margin-bottom: 10px; font-size: 18px; display: inline-block;">自动投标状态：@(Model.ID > 0 ? "已开启" : "已关闭")</span><br/>

                    <div>
                        <h3 class="">自动投资工具说明</h3>
                        <p class="">1、自动投资工具会根据用户设置的每次投资金额、最小投资金额，结合用户的账户可用余额向符合设置条件的项目进行投资，具体规则如下：</p>
                        <p class="">
                            a、账户可用余额 &lt; 最小投资金额，不执行自动投资；<br/>
                            b、最小投资金额 &lt;= 账户可用余额&lt;每次投资金额元，执行自动投资，投资金额为账户可用余额的整数部分；<br/>
                            c、每次投资金额 &lt;= 账户可用余额，执行自动投资，投资金额为设定的每次投资金额。
                        </p>
                        <p class="">2、用户开启此工具，并完成条件设置后，自动投资功能将在新标开始五分钟启动，如果满足条件，将为您自动投标；</p>
                        <p class="">3、投资序列按照用户设置自动投标时间先后来进行，用户投标成功一次后，重新排队加入；</p>
                    </div>

                    <div style="text-align: center;margin-top: 38px;" class="@(Model.ID > 0 ? "hide" : "")">
@*                        <button class="Mycolor auto-btn" onclick="lazy_autobid();">开启懒人型一键式自动投标</button>*@
                        <button class="Mycolor auto-btn" style="margin-left: 28px;" onclick="diy_autobid();">开启稳健型自主式自动投标</button>
                    </div>
                    
                    <div style="text-align: center;margin-top: 38px;" class="@(Model.ID > 0 ? "" : "hide")">
                        <a href="@Url.Action("TurnAutoBid")"><button class="Mycolor auto-btn">关闭自动投标功能</button></a>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<div class="ui-layer" id="dialog_lazy_autobid">
    <div class="lymask">
    </div>
    <table class="lytable">
        <tbody>
            <tr>
                <td class="lytd">
                    <div class="lywrap">
                        <div class="lytt">
                            <h2 class="u-tt">自动投标</h2>
                            <a href="javascript:void(0)" onclick=" closeCredit() ">
                                <span class="lyclose">×</span>
                            </a>
                        </div>
                        <div class="lyct" id="lazy_autobid_form" style="font-size: 16px;">
                            <table class="autobid_form_table">
                                <tr>
                                    <td class="title">账户余额：</td>
                                    <td class="content">@ViewBag.Money.ToString("0.00") (元)</td>
                                </tr>
                                <tr>
                                    <td class="title">每次投资金额：</td>
                                    <td class="content">1000.00元</td>
                                </tr>
                                <tr>
                                    <td class="title">最小投资金额：</td>
                                    <td class="content">1000.00元</td>
                                </tr>
                                <tr>
                                    <td class="title">利息范围：</td>
                                    <td class="content">大于9.00%</td>
                                </tr>
                                <tr>
                                    <td class="title">借款期限：</td>
                                    <td class="content">小于12个月</td>
                                </tr>
                                <tr>
                                    <td class="title">账户保留金额：</td>
                                    <td class="content">0.00元</td>
                                </tr>
                            </table>
                        </div>
                        <div class="lybt">
                            <div style="text-align: center;">
                                <a href="@Url.Action("LazySettingAutoBid")">
                                    <button type="button" onclick="submit_lazy_autobid()" class="ui-button ui-button-red big" style="margin-right: 18px;">设置</button>
                                </a>
                                <button type="button" onclick="closeCredit()" class="ui-button ui-button-gray big">取消</button>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>

<div class="ui-layer" id="dialog_diy_autobid">
    <div class="lymask">
    </div>
    <table class="lytable">
        <tbody>
            <tr>
                <td class="lytd">
                    <div class="lywrap">
                        <div class="lytt">
                            <h2 class="u-tt">自动投标</h2>
                            <a href="javascript:void(0)" onclick=" closeCredit() ">
                                <span class="lyclose">×</span>
                            </a>
                        </div>
                            <form method="post" action="@Url.Action("AutoBidSetting")" id="frmAutoBidSetting">
                        <div class="lyct" id="diy_autobid_form" style="font-size: 16px;">
                                <table class="autobid_form_table diy">
                                <tr>
                                    <td class="title">账户余额：</td>
                                    <td class="content">@ViewBag.Money.ToString("0.00") (元)</td>
                                </tr>
                                <tr>
                                    <td class="title">最大投资金额：</td>
                                    <td class="content"><input class="ui-input" type="text" value="1000" id="LoadMoney" name="LoadMoney"/> 元</td>
                                </tr>
                                <tr>
                                    <td class="title">最小投资金额：</td>
                                    <td class="content"><input class="ui-input" type="text" value="1000" id="MinLoadMoney" name="MinLoadMoney"/> 元</td>
                                </tr>
                                <tr>
                                    <td class="title">利息范围：</td>
                                    <td class="content">
                                        <select id="MoneyRateLowerLimit" name="MoneyRateLowerLimit" class="ui-input">
                                            <option value="10">10.00% - 20.00%</option>
                                            <option value="12">12.00% - 20.00%</option>
                                            <option value="14">14.00% - 20.00%</option>
                                            <option value="16">16.00% - 20.00%</option>
                                            <option value="18">18.00% - 20.00%</option>
                                            <option value="20">20.00% - 20.00%</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="title">借款期限：</td>
                                    <td class="content">
                                        <select name="DealDateUpperLimit" id="DealDateUpperLimit" class="ui-input">
                                            <option value="3">0个月 - 3个月</option>
                                            <option value="6">0个月 - 6个月</option>
                                            <option value="9">0个月 - 9个月</option>
                                            <option value="12" selected="selected">0个月 - 12个月</option>
                                            <option value="18">0个月 - 18个月</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="title">账户保留金额：</td>
                                    <td class="content"><input class="ui-input" value="0.00" type="text" id="RetainMoney" name="RetainMoney"/> 元</td>
                                </tr>
                            </table>
                        </div>
                        <div class="lybt">
                            <div style="text-align: center;">
                                <input type="submit" onclick="submit_diy_autobid()"  class="ui-button ui-button-red big" style="margin-right: 18px;" value="设置"/>
                                <button type="button" onclick="closeCredit()" class="ui-button ui-button-gray big">取消</button>
                            </div>
                        </div>
                            </form>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>

<div style="margin-top: -10px;">@Html.Partial("_BindBottomImage")</div>

<script type="text/javascript">

    function lazy_autobid() {
        $('#dialog_lazy_autobid').addClass("ui-layer-show");
    }

    function diy_autobid() {
        $('#dialog_diy_autobid').addClass("ui-layer-show");
    }

    function closeCredit() {
        $('#dialog_diy_autobid').removeClass("ui-layer-show");
        $('#dialog_lazy_autobid').removeClass("ui-layer-show");
    }

    function submit_lazy_autobid() {
        closeCredit();
    }

    function submit_diy_autobid() {
        closeCredit();
    }

</script>

<script type="text/javascript">
    $(document).ready(function () {
        if ($('#AutoBidId').val() === "0") {
            $('.fieldsethide').hide();
            $('#btnCloseAutoBid').val("取消");

        } else {
            $('#btnOpenAutoBind').hide();
            $('#lblAutoBidStatus').text('已开启');
        }
        var count = 0;
        $('#btnOpenAutoBind').click(function () {
            if (count % 2 === 0) {
                $(this).hide();
                $('.fieldsethide').show();
            } else {
                $('.fieldsethide').hide();
            }
            count++;
        });
        $('#btnCloseAutoBid').click(function () {
            if ($('#AutoBidId').val() === "0") {
                $('.fieldsethide').hide();
                $('#btnOpenAutoBind').show();
                count = 0;
            } else {
                $('#frmAutoBidSetting').attr('action', '@Url.Action("TurnAutoBid")');
                $('#frmAutoBidSetting').submit();
            }
        });
        $('#btnSubmit').bind("click", function () {
            //            if (!$('#chkIsAgreement').is(":checked")) {
            //                alert("请同意自动投标协议");
            //                event.returnValue = false;
            //                return;
            //            }
        });
        var moneyRateLowerLimit = "@Model.MoneyRateLowerLimit";
        var dealDateUpperLimit = "@Model.DealDateUpperLimit";
        $('#MoneyRateLowerLimit').find('option[value="' + moneyRateLowerLimit + '"]').attr('selected', true);
        $('#DealDateUpperLimit').find('option[value="' + dealDateUpperLimit + '"]').attr('selected', true);

    });

</script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#frmAutoBidSetting').validate({
            rules: {
                LoadMoney: {
                    required: true,
                    min: 200,
                    number: true
                },
                MinLoadMoney: {
                    required: true,
                    number: true,
                    min: 50
                },
                RetainMoney: {
                    required: true,
                    number: true,
                    min: 0
                }
            },
            messages: {
                LoadMoney: {
                    required: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入每次投资金额！</span>",
                    min: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入不小于200的整数！</span>",
                    number: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入数字！</span>"
                },
                MinLoadMoney: {
                    required: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入最小投资金额！</span>",
                    min: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入不小于50的整数！</span>",
                    number: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入数字！</span>"
                },
                RetainMoney: {
                    required: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入账户保留金额！</span>",
                    min: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入不小于50的整数！</span>",
                    number: "<i class='ui-tiptext-icon iconfont' id='iusername-error'  title='出错'>&#xf0155;</i><span  style='color:Red;'>请输入数字！</span>"
                }
            },
            errorPlacement: function (error, element) {
                if (element.is("#LoadMoney")) {
                    error.appendTo('#load-money-error');
                }
                else if (element.is("#MinLoadMoney")) {
                    error.appendTo('#min-loadmoney-error');
                }
                else if (element.is("#RetainMoney")) {
                    error.appendTo('#retain-error');
                }
            }
        });
    });
</script>
